package com.heima.user.feign;

import com.heima.apis.user.IUserClient;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.model.user.pojo.ApUser;
import com.heima.user.service.ApUserRealnameService;
import com.heima.user.service.ApUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserClient implements IUserClient {

    @Autowired
    private ApUserRealnameService apUserRealnameService;
    /**
     * 按照状态分页查询用户列表
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/user/feign/load_user_realname_list")
    @Override
    public PageResponseResult loadListByStatus(@RequestBody AuthDto dto) {
        return apUserRealnameService.loadListByStatus(dto);
    }

    /**
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/user/feign/update_status")
    @Override
    public ResponseResult updateStatus(@RequestBody AuthDto dto) {
        return apUserRealnameService.updateStatus(dto);
    }

    @Autowired
    private ApUserService apUserService;

    @Override
    @GetMapping("/api/v1/user/{id}")
    public ApUser findUserById(@PathVariable("id") Integer id) {
        return apUserService.getById(id);
    }
}
